const list = []
export default {
	name(state) {
		return state.name
	},
	// get
	get_result(state) {
		let data = state.result
		let storage = window.localStorage
		let arr = []
		/*
			检测localStorage中是否有本次查询的数据
			如果没有则添加到localStorage
			如果有则更新
			只保存十条
		 */
		// 缓存已查询过的设备号
		for (let i in data) {
			if (!storage.device) {
				arr.push(data[i].serialId)
				storage.setItem('device', JSON.stringify(arr))
				list.push(data[i])
			} else {
				let id = JSON.parse(storage.getItem('device'))
				if (id.indexOf(data[i].serialId) === -1 && id.length < 10) {
					id.push(data[i].serialId)
					storage.setItem('device', JSON.stringify(id))
					list.push(data[i])
				} else {
					// 判断list是否有当前数据，如果有则更新
					list.push(data[i])
				}
			}
		}
		return list
	},
	// loading
	get_loading(state) {
		return state.loading
	}
}
